---
title: "SNSF initial DMP data"
subtitle: "Descriptive statistics and figures"
author: "G.Fraga Gonzalez"
affiliation: "Center for Reproducible Science, UZH"
date: last-modified
format:
html:
self-contained: true
page-layout: full
toc: true
code-fold: true
code-copy: true
code-tools: true
---
## Descriptive statistics
```{r readData}
#| echo: false
#| warning: false
#| tbl-cap-location: top
library(purrr)
# paths
dirinput <- file.path(getwd())
fileinput <- 'SNSF_ORD_monitoring_report_2017-2018_dataset.xlsx'
sheet_apps <- 'Data_applications'
sheet_repo <- 'Data_repositories'
# read tables
tbl_apps <- as.data.frame(readxl::read_xlsx(fileinput,sheet = sheet_apps))
tbl_repo <- as.data.frame(readxl::read_xlsx(fileinput,sheet = sheet_repo))
```
The input file: **`r fileinput`** was downloaded from <https://zenodo.org/records/3618209>
::: {.panel-tabset}
# Application data
The table in sheet *`r sheet_apps`* has *`r nrow(tbl_apps)`* *rows* and *`r ncol(tbl_apps)`* *columns*.
```{r render}
#| warning: false
#| echo: false
library(htmltools)
library(dplyr)
library(plotly)
library(crosstalk) # this package makes it possible to filter
library(DT)
# Create object that will be shared by filter panels, datatable and plots
shared_tbl <- SharedData$new(tbl_apps, group = "shared_obj")
# filter panels. Other formats are sliders and checkboxes https://rstudio.github.io/crosstalk/using.html
#--------------------------------------------------------------------------------
bscols(
widths = c(2,3,3,3,3),
device = c("xs", "sm", "md", "lg"),
filter_checkbox( id = "Division", label = "Division",sharedData = shared_tbl, group = ~Division, inline=FALSE),
filter_select(id = "repository", label = "Filter by Repository",sharedData = shared_tbl, ~`Data repository`),
filter_select(id = "categories", label = "Filter by Sharing Category",sharedData = shared_tbl, ~`Categories`),
filter_select(id = "dmpcheck", label = "Filter by DMP check",sharedData = shared_tbl, ~`DMP check`),
filter_select(id = "dmpsubmit", label = "Filter by DMP submission",sharedData = shared_tbl, ~`DMP submitted`)
)
# Plot
#--------------------------------------------------------------------------------
bscols(
widths = c(6,6),
plot_ly(shared_tbl, y = ~`Budgeted ORD costs`, x = ~Division, color=~Division) %>%
add_markers(),
plot_ly(shared_tbl, x = ~`DMP check`, color=~Division,alpha = 0.6) %>%
add_histogram(),
tags$hr(),
tags$hr()
)
tags$hr()
# table
#--------------------------------------------------------------------------------
datatable(
shared_tbl,
filter = "top",
rownames = FALSE,
class = 'compact cell-border hover stripe',
extensions = c('Buttons', 'ColReorder', 'Scroller', 'KeyTable'),
selection = 'none',
options = list(
initComplete = JS("function(settings, json) {$(this.api().table().header()).css({'font-size' : '80%'});}"), #reduce header font
dom = 'Bfrtip',
buttons = list('copy'),
scrollX = TRUE,
scrollY = "400px",
colReorder = TRUE
)
) %>%
DT::formatStyle(columns = c(1:9), fontSize = '75%')
```
# Repository data
The table: *`r sheet_repo`* has *`r nrow(tbl_repo)`* *rows* and *`r ncol(tbl_repo)`* *columns*.
```{r render2}
#| warning: false
#| echo: false
library(htmltools)
library(dplyr)
library(plotly)
library(crosstalk)
library(DT)
# Create object that will be shared by filter panels, datatable and plots
shared_tbl <- SharedData$new(tbl_repo, group = "shared_obj")
# filter panels
#--------------------------------------------------------------------------------
bscols(
widths = c(2,3,3,3),
device = c("xs", "sm", "md", "lg"),
filter_checkbox( id = "fair", label = "SNSF FAIR criteria",sharedData = shared_tbl, group = ~`SNSF FAIR criteria`, inline=FALSE),
filter_select(id = "repository", label = "Filter by Repository",sharedData = shared_tbl, ~`Data repository`),
filter_select(id = "country", label = "Country",sharedData = shared_tbl, ~`Country (involvement)`)
)
# Plot
#--------------------------------------------------------------------------------
bscols(
widths = c(6,6),
plot_ly(shared_tbl, y = ~Occurrence , x = ~`Country (involvement)`, color=~`Country (involvement)`) %>%
add_markers(),
plot_ly(shared_tbl, x = ~Occurrence , color=~`Country (involvement)`,alpha = 0.6) %>%
add_histogram(),
tags$hr(), # adds some horizontal line for extra space
tags$hr()
)
tags$hr()
# table
#--------------------------------------------------------------------------------
datatable(
shared_tbl,
filter = "top",
rownames = FALSE,
class = 'compact cell-border hover stripe',
extensions = c('Buttons', 'ColReorder', 'Scroller', 'KeyTable'),
selection = 'none',
options = list(
initComplete = JS("function(settings, json) {$(this.api().table().header()).css({'font-size' : '80%'});}"), #reduce header font
dom = 'Bfrtip',
buttons = list('copy'),
scrollX = TRUE,
scrollY = "400px",
colReorder = TRUE
)
) %>%
DT::formatStyle(columns = c(1:9), fontSize = '75%')
```
:::